import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm';

@Entity('user')
export class User {
    @PrimaryGeneratedColumn()
    id: number;

    @Column({ length: 50, unique: true, comment: '用户名' })
    username: string;

    @Column({ length: 255, comment: '密码（加密存储）' })
    password: string;

    @Column({ length: 50, comment: '姓名' })
    name: string;

    @Column({ type: 'enum', enum: ['男', '女'], comment: '性别' })
    gender: string;

    @Column({ type: 'tinyint', unsigned: true, nullable: true, comment: '年龄' })
    age: number;

    @Column({ length: 20, nullable: true, comment: '联系电话' })
    phone: string;

    @Column({ length: 100, nullable: true, comment: '邮箱' })
    email: string;

    @Column({ length: 50, nullable: true, comment: '班级（仅学生）' })
    class: string;

    @CreateDateColumn({ comment: '创建时间' })
    created_at: Date;

    @UpdateDateColumn({ comment: '更新时间' })
    updated_at: Date;
}